package com.smartalarmclock.Model;

import java.util.Set;

import android.content.Context;

import com.smartalarmclock.Model.Exceptions.DataEntityDoesNotExistException;
import com.smartalarmclock.Model.ITimeFrame.TimeInWeek;

public final class TimeFrameFactory implements IDataEntityFactory {

	/**
	 * Creates a new TimeFrame
	 * @param startTime the start time
	 * @param endTime the end time
	 */
	public ITimeFrame CreateTimeFrame(TimeInWeek startTime, TimeInWeek endTime) {
		return new TimeFrame(startTime, endTime);
	}
	
	/**
	 * Queries a TimeFrame instance with the given id
	 * @param context the context of the request
	 * @param id the id to query
	 * @return the matching TimeFrame
	 * @throws DataEntityDoesNotExistException if the matching TimeFrame does not exist
	 */
	public ITimeFrame GetTimeFrameById(Context context, int id) throws DataEntityDoesNotExistException {
		return TimeFrame.GetTimeFrameById(context, id);
	}
	
	/**
	 * Queries a TimeFrame instance with the given id
	 * @param context the context of the request
	 * @param id the id to query
	 * @return the matching TimeFrame or null if it does not exist
	 */
	public ITimeFrame TryGetTimeFrameById(Context context, int id) {
		return TimeFrame.TryGetTimeFrameById(context, id);
	}
	
	/**
	 * Queries time frames matching the given time range.
	 * @param context the context of the request
	 * @return a collection of time frames matching the given time range.
	 */
	public Set<ITimeFrame> GetTimeFramesByTimeRange(Context context, TimeInWeek startTime, TimeInWeek endTime) {
		return TimeFrame.GetTimeFramesByTimeRange(context, startTime, endTime);
	}
}
